#include <iostream>
#include <unistd.h>
using namespace std;

int main(){
    int i = 0;
    int pid = fork();

    if(pid > 0){
        cout << "父进程，pid=" << getpid() << endl;
        cout << i++ << endl;
        cout << i++ << endl;
        cout << i++ << endl;
        cout << i++ << endl;
    }

    if(pid == 0){
        cout << "子进程，pid=" << getpid() << endl;
        cout << i << endl;
        cout << i << endl;
        cout << i << endl;
        cout << i << endl;
    }

}